home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / PCI Driver Development Kit / • Tools / Utility / DisplayNameRegistry 950412 / Src / SpinCursor.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-27  |  1.5 KB  |  68 lines  |  [TEXT/MPCC]

  1. /*                                    SpinCursor.c                                */
  2. /*
  3.  * SpinCursor.c
  4.  * Copyright © 1993-94 Apple Computer Inc. All rights reserved.
  5.  * This is based on a sample in Think Reference 2.0.
  6.  */
  7. #include "DisplayNameRegistry.h"
  8. #include "IntlResources.h"
  9. #include "Script.h"
  10. #include "TextUtils.h"
  11. #include "SegLoad.h"
  12. #include "FixMath.h"
  13. #include "ToolUtils.h"
  14. #define ACUR    (**gACUR_Handle)
  15.  
  16. /*
  17.  * SetupAnimatedCursor
  18.  * Build the animated cursor handle array (in global gACUR_Handle)
  19.  */
  20. void
  21. SetupAnimatedCursor(
  22.         short                        acurResID
  23.     )
  24. {
  25.         short                    cursorID;
  26.         short                    i;
  27.  
  28.         gACUR_Handle = (ACUR_Handle) GetResource('acur', acurResID);
  29.         if (gACUR_Handle != NULL) {
  30.             DetachResource((Handle) gACUR_Handle);
  31.             for (i = 0; i < ACUR.nFrames; i++) {
  32.                 cursorID = ((unsigned long) ACUR.frame[i]) >> 16;
  33.                 ACUR.frame[i] = GetCursor(cursorID);
  34.                 if (ACUR.frame[i] == NULL)
  35.                     break;
  36.                 HNoPurge((Handle) ACUR.frame[i]);
  37.             }
  38.             ACUR.nFrames = i;
  39.             ACUR.nextFrame = 0;
  40.             if (i == 0) {
  41.                 DisposeHandle((Handle) gACUR_Handle);
  42.                 gACUR_Handle = NULL;
  43.             }
  44.         }
  45.         gACUR_NextAnimation = 0;
  46. }
  47.  
  48. /*
  49.  * SpinCursor
  50.  * This is called repeatedly to change the cursor animation.
  51.  */
  52. void
  53. SpinCursor(void)
  54. {
  55.         unsigned long                now;
  56.         
  57.         if (gACUR_Handle != NULL) {
  58.             now = TickCount();
  59.             if (now > gACUR_NextAnimation) {
  60.                 gACUR_NextAnimation = now + kAnimationInterval;
  61.                 if (ACUR.nextFrame >= ACUR.nFrames)
  62.                     ACUR.nextFrame = 0;
  63.                 SetCursor(*ACUR.frame[ACUR.nextFrame]);
  64.                 ++ACUR.nextFrame;
  65.             }
  66.         }
  67. }
  68.